﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Common;
using System.Data;
using System.ComponentModel;
namespace pms.FeeMgr
{
    public partial class WebUserControlDropDownListBox : System.Web.UI.UserControl
    {
        private Boolean _autopostback = false;
        private String _Text = "CarryForward_Type";
        private String _KindFieldName = "CarryForward_Type";
        [Bindable(false),

        Category("Data"),

        DefaultValue("CarryForward_Type")] 

        public string KindFieldName
        {
            get { return _KindFieldName; }
            set { _KindFieldName = value; }
        }


        [Bindable(true),
        Category("Data"),
        DefaultValue(""),
        Browsable(true)]  
        public string Text
        {
            get { return _Text; }
            set { _Text = value; }
        }


        [Bindable(false),

        Category("Data"),

        DefaultValue(false)] 

        public Boolean autopostback
        {
            get { return _autopostback; }
            set { _autopostback = value; }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            DropDownList1.AutoPostBack = autopostback;
            setdropdownkindfield(KindFieldName);
        }

        protected void Button1_Click(object sender, EventArgs e)
        {

        }
        public void setdropdownkindfield(string fieldname)
        {
            String Sql;
            DataSet ds;
            Sql = "sElect ";
            Sql+=" adm_dropdownlist.listname from adm_dropdownkind ,adm_dropdownlist ";
            Sql+=" where adm_dropdownkind.pdropdownkindid=adm_dropdownlist.pdropdownkindid ";
            Sql+= " and upper( adm_dropdownkind.kindfieldname)=upper('" + fieldname + "')";
            ds = DbHelperSQL.Query(Sql);
            DataView dvTree = new DataView(ds.Tables[0]);
            DropDownList1.Items.Clear();
            foreach (DataRowView Row in dvTree)
            {
                DropDownList1.Items.Add(Row["LISTNAME"].ToString());
            }

        }
    }
}